package com.rabbitmq.producer.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author: Thomas
 * @Date: 2024-01-21  10:26:29
 * @Description:
 */
@Configuration
public class DLQConfig {

    // 1. 声明交换机fanout【创建交换机】
    @Bean
    public DirectExchange directTLEExchange(){
        // 持久化 不自动删除
        return new DirectExchange("direct_dlx_order_exchange", true, false);
    }
    // 2. 声明队列 sms.fanout.queue  email.fanout.queue  message.fanout.queue 【创建队列】
    @Bean
    public Queue dlq01(){
        return new Queue("direct.qlq.1.queue", true);
    }

    @Bean
    public Queue dlq02(){
        return new Queue("direct.qlq.2.queue", true);
    }

    // 3. 完成绑定关系
    @Bean
    public Binding tlq1Binding(){
        return BindingBuilder.bind(dlq01()).to(directTLEExchange()).with("dead1");
    }

    @Bean
    public Binding tlq2Binding(){
        return BindingBuilder.bind(dlq02()).to(directTLEExchange()).with("dead2");
    }

}
